home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / cert / trk3_eg / fmdrgdrp / opt2 / invent.exe / ORDER.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-08-20  |  17.6 KB  |  524 lines

  1. VERSION 2.00
  2. Begin Form OrderForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Order"
  5.    ClientHeight    =   4335
  6.    ClientLeft      =   1560
  7.    ClientTop       =   2130
  8.    ClientWidth     =   5460
  9.    Height          =   4740
  10.    HelpContextID   =   105
  11.    Icon            =   ORDER.FRX:0000
  12.    Left            =   1500
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    MDIChild        =   -1  'True
  16.    ScaleHeight     =   4335
  17.    ScaleWidth      =   5460
  18.    Top             =   1785
  19.    Width           =   5580
  20.    Begin TextBox Total 
  21.       BackColor       =   &H00808080&
  22.       BorderStyle     =   0  'None
  23.       DataField       =   "Total"
  24.       DataSource      =   "Data2"
  25.       ForeColor       =   &H00FFFFFF&
  26.       Height          =   255
  27.       Left            =   4320
  28.       TabIndex        =   16
  29.       Top             =   1020
  30.       Width           =   1035
  31.    End
  32.    Begin TextBox Text1 
  33.       BorderStyle     =   0  'None
  34.       DataField       =   "ShipZip"
  35.       DataSource      =   "Data2"
  36.       FontBold        =   0   'False
  37.       FontItalic      =   0   'False
  38.       FontName        =   "MS Sans Serif"
  39.       FontSize        =   8.25
  40.       FontStrikethru  =   0   'False
  41.       FontUnderline   =   0   'False
  42.       Height          =   255
  43.       Index           =   5
  44.       Left            =   2760
  45.       TabIndex        =   15
  46.       Text            =   "Text1"
  47.       Top             =   1080
  48.       Width           =   975
  49.    End
  50.    Begin TextBox Text1 
  51.       BorderStyle     =   0  'None
  52.       DataField       =   "ShipState"
  53.       DataSource      =   "Data2"
  54.       FontBold        =   0   'False
  55.       FontItalic      =   0   'False
  56.       FontName        =   "MS Sans Serif"
  57.       FontSize        =   8.25
  58.       FontStrikethru  =   0   'False
  59.       FontUnderline   =   0   'False
  60.       Height          =   255
  61.       Index           =   4
  62.       Left            =   2220
  63.       TabIndex        =   14
  64.       Text            =   "Text1"
  65.       Top             =   1080
  66.       Width           =   555
  67.    End
  68.    Begin TextBox Text1 
  69.       BorderStyle     =   0  'None
  70.       DataField       =   "ShipCity"
  71.       DataSource      =   "Data2"
  72.       FontBold        =   0   'False
  73.       FontItalic      =   0   'False
  74.       FontName        =   "MS Sans Serif"
  75.       FontSize        =   8.25
  76.       FontStrikethru  =   0   'False
  77.       FontUnderline   =   0   'False
  78.       Height          =   255
  79.       Index           =   3
  80.       Left            =   660
  81.       TabIndex        =   13
  82.       Text            =   "Text1"
  83.       Top             =   1080
  84.       Width           =   1575
  85.    End
  86.    Begin TextBox Text1 
  87.       BorderStyle     =   0  'None
  88.       DataField       =   "ShipAddr"
  89.       DataSource      =   "Data2"
  90.       FontBold        =   0   'False
  91.       FontItalic      =   0   'False
  92.       FontName        =   "MS Sans Serif"
  93.       FontSize        =   8.25
  94.       FontStrikethru  =   0   'False
  95.       FontUnderline   =   0   'False
  96.       Height          =   495
  97.       Index           =   2
  98.       Left            =   660
  99.       MultiLine       =   -1  'True
  100.       TabIndex        =   12
  101.       Text            =   "Text1"
  102.       Top             =   600
  103.       Width           =   3075
  104.    End
  105.    Begin TextBox Text1 
  106.       BackColor       =   &H00808000&
  107.       BorderStyle     =   0  'None
  108.       DataField       =   "OrderNo"
  109.       DataSource      =   "Data2"
  110.       ForeColor       =   &H00FFFFFF&
  111.       Height          =   255
  112.       Index           =   1
  113.       Left            =   2820
  114.       TabIndex        =   11
  115.       Text            =   "Text1"
  116.       Top             =   60
  117.       Width           =   855
  118.    End
  119.    Begin TextBox Text1 
  120.       BorderStyle     =   0  'None
  121.       DataField       =   "CustName"
  122.       DataSource      =   "Data2"
  123.       FontBold        =   0   'False
  124.       FontItalic      =   0   'False
  125.       FontName        =   "MS Sans Serif"
  126.       FontSize        =   8.25
  127.       FontStrikethru  =   0   'False
  128.       FontUnderline   =   0   'False
  129.       Height          =   255
  130.       Index           =   0
  131.       Left            =   660
  132.       TabIndex        =   10
  133.       Text            =   "Text1"
  134.       Top             =   360
  135.       Width           =   3075
  136.    End
  137.    Begin Data Data2 
  138.       Caption         =   "Data2 - Header"
  139.       Connect         =   ""
  140.       DatabaseName    =   ""
  141.       Exclusive       =   0   'False
  142.       Height          =   315
  143.       Left            =   300
  144.       Options         =   0
  145.       ReadOnly        =   0   'False
  146.       RecordSource    =   ""
  147.       Top             =   3780
  148.       Visible         =   0   'False
  149.       Width           =   3375
  150.    End
  151.    Begin Data Data1 
  152.       Caption         =   "Data1 - Line Items"
  153.       Connect         =   ""
  154.       DatabaseName    =   ""
  155.       Exclusive       =   0   'False
  156.       Height          =   315
  157.       Left            =   300
  158.       Options         =   0
  159.       ReadOnly        =   0   'False
  160.       RecordSource    =   ""
  161.       Top             =   3360
  162.       Visible         =   0   'False
  163.       Width           =   3375
  164.    End
  165.    Begin TgDemo LineItems 
  166.       BackColor       =   &H00C0C0C0&
  167.       BorderStyle     =   0  'None
  168.       Configurable    =   0   'False
  169.       DataSource      =   "Data1"
  170.       Editable        =   -1  'True
  171.       EditBackColor   =   &H8000000D&
  172.       EditForeColor   =   &H8000000E&
  173.       FetchMode       =   0  'By cell
  174.       HeadBackColor   =   &H000000C0&
  175.       HeadForeColor   =   &H00FFFFFF&
  176.       Headings        =   -1  'True
  177.       Height          =   1695
  178.       HorzColor       =   &H00808080&
  179.       HorzLines       =   2  '3D
  180.       InactiveBackColor=   &H00808080&
  181.       InactiveForeColor=   &H00000080&
  182.       Layout          =   ORDER.FRX:0302
  183.       Left            =   0
  184.       MarqueeStyle    =   1  'Solid Cell Border
  185.       SelectedBackColor=   &H00000000&
  186.       SelectedForeColor=   &H00FFFFFF&
  187.       SelectMode      =   0  'Disabled
  188.       TabIndex        =   9
  189.       Top             =   1440
  190.       UseBookmarks    =   -1  'True
  191.       VertColor       =   &H00808080&
  192.       VertLines       =   2  '3D
  193.       Width           =   5415
  194.    End
  195.    Begin TextBox Tax 
  196.       Alignment       =   1  'Right Justify
  197.       BackColor       =   &H00808080&
  198.       BorderStyle     =   0  'None
  199.       ForeColor       =   &H00FFFFFF&
  200.       Height          =   255
  201.       Left            =   4320
  202.       TabIndex        =   4
  203.       TabStop         =   0   'False
  204.       Top             =   720
  205.       Width           =   1035
  206.    End
  207.    Begin TextBox SubTot 
  208.       Alignment       =   1  'Right Justify
  209.       BackColor       =   &H00808080&
  210.       BorderStyle     =   0  'None
  211.       ForeColor       =   &H00FFFFFF&
  212.       Height          =   255
  213.       Left            =   4320
  214.       TabIndex        =   3
  215.       TabStop         =   0   'False
  216.       Top             =   420
  217.       Width           =   1035
  218.    End
  219.    Begin Label Label3 
  220.       Alignment       =   1  'Right Justify
  221.       BackColor       =   &H00C0C0C0&
  222.       Caption         =   "Order#"
  223.       Height          =   255
  224.       Left            =   1680
  225.       TabIndex        =   8
  226.       Top             =   60
  227.       Width           =   1035
  228.    End
  229.    Begin Label Label2 
  230.       Alignment       =   1  'Right Justify
  231.       BackColor       =   &H00C0C0C0&
  232.       Caption         =   "Total:"
  233.       FontBold        =   0   'False
  234.       FontItalic      =   0   'False
  235.       FontName        =   "MS Sans Serif"
  236.       FontSize        =   8.25
  237.       FontStrikethru  =   0   'False
  238.       FontUnderline   =   0   'False
  239.       Height          =   255
  240.       Index           =   2
  241.       Left            =   3840
  242.       TabIndex        =   7
  243.       Top             =   1020
  244.       Width           =   435
  245.    End
  246.    Begin Label Label2 
  247.       Alignment       =   1  'Right Justify
  248.       BackColor       =   &H00C0C0C0&
  249.       Caption         =   "Tax:"
  250.       FontBold        =   0   'False
  251.       FontItalic      =   0   'False
  252.       FontName        =   "MS Sans Serif"
  253.       FontSize        =   8.25
  254.       FontStrikethru  =   0   'False
  255.       FontUnderline   =   0   'False
  256.       Height          =   255
  257.       Index           =   1
  258.       Left            =   3840
  259.       TabIndex        =   6
  260.       Top             =   720
  261.       Width           =   435
  262.    End
  263.    Begin Label Label2 
  264.       Alignment       =   1  'Right Justify
  265.       BackColor       =   &H00C0C0C0&
  266.       Caption         =   "Sub:"
  267.       FontBold        =   0   'False
  268.       FontItalic      =   0   'False
  269.       FontName        =   "MS Sans Serif"
  270.       FontSize        =   8.25
  271.       FontStrikethru  =   0   'False
  272.       FontUnderline   =   0   'False
  273.       Height          =   255
  274.       Index           =   0
  275.       Left            =   3840
  276.       TabIndex        =   5
  277.       Top             =   420
  278.       Width           =   435
  279.    End
  280.    Begin Label Label1 
  281.       Alignment       =   1  'Right Justify
  282.       BackColor       =   &H00C0C0C0&
  283.       Caption         =   "City:"
  284.       FontBold        =   0   'False
  285.       FontItalic      =   0   'False
  286.       FontName        =   "MS Sans Serif"
  287.       FontSize        =   8.25
  288.       FontStrikethru  =   0   'False
  289.       FontUnderline   =   0   'False
  290.       Height          =   255
  291.       Index           =   2
  292.       Left            =   0
  293.       TabIndex        =   2
  294.       Top             =   1080
  295.       Width           =   615
  296.    End
  297.    Begin Label Label1 
  298.       Alignment       =   1  'Right Justify
  299.       BackColor       =   &H00C0C0C0&
  300.       Caption         =   "Address:"
  301.       FontBold        =   0   'False
  302.       FontItalic      =   0   'False
  303.       FontName        =   "MS Sans Serif"
  304.       FontSize        =   8.25
  305.       FontStrikethru  =   0   'False
  306.       FontUnderline   =   0   'False
  307.       Height          =   255
  308.       Index           =   1
  309.       Left            =   0
  310.       TabIndex        =   1
  311.       Top             =   600
  312.       Width           =   615
  313.    End
  314.    Begin Label Label1 
  315.       Alignment       =   1  'Right Justify
  316.       BackColor       =   &H00C0C0C0&
  317.       Caption         =   "Name:"
  318.       FontBold        =   0   'False
  319.       FontItalic      =   0   'False
  320.       FontName        =   "MS Sans Serif"
  321.       FontSize        =   8.25
  322.       FontStrikethru  =   0   'False
  323.       FontUnderline   =   0   'False
  324.       Height          =   255
  325.       Index           =   0
  326.       Left            =   0
  327.       TabIndex        =   0
  328.       Top             =   360
  329.       Width           =   615
  330.    End
  331. ' Variables local to this form instance
  332. Dim FormIndex As Integer
  333. Dim ourOrderNo As Long
  334. Dim WidthDelta As Integer
  335. Dim ourset As DynaSet
  336. Sub Data1_Validate (Action As Integer, Save As Integer)
  337.     ' Recalculate the current line into the total if
  338.     ' necessary
  339.     If Save Then
  340.         RecalcItem
  341.     End If
  342. End Sub
  343. Sub Form_Deactivate ()
  344.     Data1.Recordset.Update
  345. End Sub
  346. Sub Form_DragDrop (Source As Control, x As Single, Y As Single)
  347.     valid% = EndDragMode(MASK_NONE)
  348. End Sub
  349. Sub Form_DragOver (Source As Control, x As Single, Y As Single, State As Integer)
  350.     valid% = DragValid(Source, MASK_NONE, State)
  351. End Sub
  352. Sub Form_GotFocus ()
  353.     SetStatus "Order form - edits line items and order header"
  354. End Sub
  355. Sub Form_Load ()
  356.     ' Determine the difference between internal and
  357.     ' external dimensions.
  358.     WidthDelta = Me.Width - Me.ScaleWidth
  359.     ' Capture information stored in OpenOrder of ORDER.BAS.
  360.     ' Use two data controls.  Data1 is for the line items,
  361.     ' Data2 is for the header ... both are stored in
  362.     ' the same table and are differentiated by the
  363.     ' IsDetail field.
  364.     FormIndex = FormLastAlloc()
  365.     Me.Tag = FormIndex
  366.     fname$ = OrderFormItems(FormIndex).fiFileName
  367.     tbname$ = OrderFormItems(FormIndex).fiTable
  368.     Data1.DatabaseName = fname$
  369.     Data2.DatabaseName = fname$
  370.     Data1.RecordSource = "SELECT * FROM [" & tbname$ & "] WHERE OrderNo = " & RecentOrderNo & " AND IsDetail"
  371.     Data2.RecordSource = "SELECT * FROM [" & tbname$ & "] WHERE OrderNo = " & RecentOrderNo & " AND NOT IsDetail"
  372.     ourOrderNo = RecentOrderNo
  373.     Data1.Refresh
  374.     Data2.Refresh
  375.     Set ourset = Data1.Recordset
  376.     RecalcTable
  377.     ' Set caption
  378.     Me.Caption = Data2.Recordset("CustName") & " - #" & Data2.Recordset("OrderNo")
  379. End Sub
  380. Sub Form_Resize ()
  381.     ' Constrain our width
  382.     If Me.WindowState = NORMAL Then
  383.         Me.Width = LineItems.Width + WidthDelta
  384.         LineItems.Height = Me.ScaleWidth - LineItems.Top
  385.     End If
  386. End Sub
  387. Sub Form_Unload (Cancel As Integer)
  388.     Data1.Recordset.Close
  389.     Data2.Recordset.Close
  390.     FormFree OrderFormItems(FormIndex)
  391. End Sub
  392. Sub LineItems_Append ()
  393.     ' should append a line item here
  394. End Sub
  395. Sub LineItems_DragDrop (Source As Control, x As Single, Y As Single)
  396.     ' Parts can be dragged from a parts table, or from
  397.     ' another order
  398.     If EndDragMode(MASK_PARTS Or MASK_ORDER) Then
  399.         Select Case DragType
  400.             Case MASK_PARTS
  401.                 ourset.AddNew
  402.                 ourset("OrderNo") = ourOrderNo
  403.                 ourset("PartNo") = Source.ColumnText(1)
  404.                 ourset("Description") = Source.ColumnText(2)
  405.                 ourset("Price") = Source.ColumnText(3)
  406.                 ourset("Quantity") = 1
  407.                 ourset("Total") = Source.ColumnText(3)
  408.                 ourset("IsDetail") = True
  409.                 ourset.Update
  410.                 RecalcTable
  411.                 ourset.MoveLast
  412.             Case MASK_ORDER
  413.                 ourset.AddNew
  414.                 ourset("OrderNo") = ourOrderNo
  415.                 ourset("PartNo") = Source.ColumnText(1)
  416.                 ourset("Description") = Source.ColumnText(2)
  417.                 ourset("Quantity") = Source.ColumnText(3)
  418.                 ourset("Price") = Source.ColumnText(4)
  419.                 ourset("Total") = Source.ColumnText(5)
  420.                 ourset("IsDetail") = True
  421.                 ourset.Update
  422.                 RecalcTable
  423.                 ourset.MoveLast
  424.         End Select
  425.     End If
  426. End Sub
  427. Sub LineItems_DragOver (Source As Control, x As Single, Y As Single, State As Integer)
  428.     valid% = DragValid(Source, MASK_PARTS Or MASK_ORDER, State)
  429. End Sub
  430. Sub LineItems_GotFocus ()
  431.     SetStatus "Editing line items - items can be dragged to other orders"
  432. End Sub
  433. Sub LineItems_KeyPress (KeyAscii As Integer)
  434.     ' ESC restores the prior line item
  435.     If KeyAscii = 27 Then Data1.UpdateControls
  436. End Sub
  437. Sub LineItems_KeyUp (KeyCode As Integer, Shift As Integer)
  438.     ' F2 updates data to the database; DEL removes
  439.     ' the line item
  440.     If KeyCode = KEY_F2 Then Data1.Recordset.Update
  441.     If KeyCode = KEY_DELETE And LineItems.HwndEdit = 0 And LineItems.Rows > 0 Then
  442.         ourset.Delete
  443.         RecalcTable
  444.         ourset.MoveFirst
  445.     End If
  446. End Sub
  447. Sub LineItems_LostFocus ()
  448.     Data1.Recordset.Update
  449. End Sub
  450. Sub LineItems_MouseDown (Button As Integer, Shift As Integer, x As Single, Y As Single)
  451.     GridMaybeDrag LineItems, x, Y
  452. End Sub
  453. Sub LineItems_MouseMove (Button As Integer, Shift As Integer, x As Single, Y As Single)
  454.     GridTestDrag LineItems, Button, x, Y, MASK_ORDER, Utils.DragRow
  455. End Sub
  456. Sub LineItems_Update (Row As Long, Col As Integer, Value As String)
  457.     ' Calculate the extended price when the price
  458.     ' or quantity is changed.
  459.     fld$ = LineItems.ColumnName(Col)
  460.     If fld$ = "Qty" Or fld$ = "Price" Then
  461.         
  462.         ' We may be at a different location than the
  463.         ' one which was updated.   Save our old location
  464.         ' and restore it.
  465.         j% = LineItems.RowIndex
  466.         i% = LineItems.ColumnIndex
  467.         LineItems.ColumnIndex = 5
  468.         LineItems.RowIndex = Row
  469.         LineItems.Text = Format$(Val(LineItems.ColumnText(4)) * Val(LineItems.ColumnText(3)), "######0.00")
  470.         LineItems.ColumnIndex = i%
  471.         LineItems.RowIndex = j%
  472.     End If
  473. End Sub
  474. Sub RecalcItem ()
  475.     ' Recalculate the total for the current item and
  476.     ' update the subtotal and total in the header
  477.     ' accordingly.
  478.     Dim Quant As Integer
  479.     Dim Price As Currency
  480.     Dim oldLineTot As Currency
  481.     Dim baseTotal As Currency
  482.     If LineItems.ColumnChanged(3) Then
  483.         Quant = LineItems.ColumnText(3)
  484.     Else
  485.         Quant = Data1.Recordset("Quantity")
  486.     End If
  487.     If LineItems.ColumnChanged(4) Then
  488.         Price = LineItems.ColumnText(4)
  489.     Else
  490.         Price = Data1.Recordset("Price")
  491.     End If
  492.     oldLineTot = Data1.Recordset("Total")
  493.     baseTotal = Val(SubTot.Text) - oldLineTot
  494.     SetTotal baseTotal + (Price * Quant)
  495. End Sub
  496. Sub RecalcTable ()
  497.     Dim tot As Currency
  498.     If ourset.RecordCount Then
  499.         ourset.MoveFirst
  500.         
  501.         While Not ourset.EOF
  502.             tot = tot + ourset("Total")
  503.             ourset.MoveNext
  504.         Wend
  505.     End If
  506.     SetTotal tot
  507. End Sub
  508. Sub SetTotal (t As Currency)
  509.     ' Set the totals.  DON'T use commas in these numbers,
  510.     ' since we sometimes take the Val() of SubTot.Text.
  511.     SubTot.Text = Format$(t, "######0.00")
  512.     Tax.Text = Format$(t * .06, "######0.00")
  513.     Total.Text = Format$(t * 1.06, "######0.00")
  514. End Sub
  515. Sub Text1_DragDrop (Index As Integer, Source As Control, x As Single, Y As Single)
  516.     valid% = EndDragMode(MASK_NONE)
  517. End Sub
  518. Sub Text1_DragOver (Index As Integer, Source As Control, x As Single, Y As Single, State As Integer)
  519.     valid% = DragValid(Source, MASK_NONE, State)
  520. End Sub
  521. Sub Text1_GotFocus (Index As Integer)
  522.     SetStatus "Editing header fields - saved when order is closed"
  523. End Sub
  524.